package ca.michaelmaguire.server.mobiledownload.server.entity;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.users.User;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class AppContents implements Serializable
{
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key		key;

	@Persistent
	private String	filename;

	@Persistent
	private Blob	content;

	@Persistent
	private User	user;

	@Persistent
	private Date	created;

	@Persistent
	private Key		secondaryappcontents;

	@Persistent
	private Key		parentappcontents;

	public Key getKey()
	{
		return key;
	}

	public void setKey(Key key)
	{
		this.key = key;
	}

	public String getFileName()
	{
		return filename;
	}

	public void setFileName(String filename)
	{
		this.filename = filename;
	}

	public Blob getContent()
	{
		return content;
	}

	public void setContent(Blob content)
	{
		this.content = content;
	}

	public User getUser()
	{
		return user;
	}

	public void setUser(User user)
	{
		this.user = user;
	}

	public Date getCreated()
	{
		return created;
	}

	public void setCreated(Date created)
	{
		this.created = created;
	}

	/**
	 * Some AppContents have secondary files, e.g. jad/jar combos.
	 */
	public Key getSecondaryAppContents()
	{
		return this.secondaryappcontents;
	}

	public void setSecondaryAppContents(Key aKeyForSecondaryAppContents)
	{
		this.secondaryappcontents = aKeyForSecondaryAppContents;
	}

	/**
	 * Some AppContents are the secondary files for a parent app content, e.g.
	 * jad/jar combos.
	 */
	public Key getParentAppContents()
	{
		return this.parentappcontents;
	}

	public void setParentAppContents(Key aKeyForParentAppContents)
	{
		this.parentappcontents = aKeyForParentAppContents;
	}

	public Long getId()
	{
		return this.key.getId();
	}
}
